Ext.define('Ext.ux.ueditor', {
    extend: 'Ext.form.field.TextArea',
    alias: 'widget.ueditor',
    initComponent: function () {
        this.callParent(arguments);

        this.on('afterrender', function () {
            Ext.apply(this.UConfig, {
                minFrameHeight: this.getHeight() - 160
            });
            //console.log(this.UConfig);
            var ue;
            if (this.UConfig)
                ue = new UE.ui.Editor(this.UConfig);
            else
                ue = new UE.ui.Editor();

            ue.render(this.inputEl.id);
            this.editor = ue;

            this.editorId = this.editor.id;
        }, this);

    },

    onRender: function (ct, position) {
        if (!this.el) {
            this.defaultAutoCreate = {
                tag: 'textarea',
                autocomplete: 'off',
            };
        }
        this.callParent(arguments);


    },
    getValue: function () {
        if (this.editor) {
            if (this.editor.hasContents())
                return this.editor.getContent();
            else
                return '';
        }
    },
    setValue: function (value) {
        this.callParent(arguments);
        if (this.editor) {
            if (this.editor.body)
                this.editor.setContent(value);
        }
    },
    getRawValue: function () {
        if (this.editor) {
            if (this.editor.body) {
                return this.editor.getContent();

            }
            else {
                return '';

            }
        } else {
            return '';
        }
    }

});

